# -*- coding: utf-8 -*-#
#-------------------------------------------------------------------------------
# 建立者:        黄周云  
# Name:         test05
# Description:  例5.5
# Author:       ASUS
# Date:         2019/1/30
#-------------------------------------------------------------------------------


# 顺序方式指定格式化参数值
s1="Today is {}, the temperature is {} degrees."
print(s1.format("saturday",24))                          #Today is saturday, the temperature is 24 degrees.
# 关键字参数方式指定格式化参数值
s2="Today is {week}, the temperature is {degree} degrees."
print(s2.format(degree=22,week="sunday"))                #Today is sunday, the temperature is 22 degrees.
#顺序方式和关键字参数方式混合使用
s3="Today is {week},{}, the {} temperature is {degree} degrees."
print(s3.format("aaaaa",12345,degree=22,week="sunday"))  #Today is sunday,aaaaa, the 12345 temperature is 22 degrees.
# 为顺序格式化参数指定从format方法获取参数值的顺序
s4="Today is {week},{1},the {0} temperature is {degree} degrees."
print(s4.format("aaaaa",12345,degree=22,week="sunday")) #Today is sunday,12345,the aaaaa temperature is 22 degrees.

# 定义一个列表
fullname=["Bill","Gates"]
print("Mr {name[1]}".format(name=fullname))              #Mr Gates

# 导入模块
import math
s5 = "The {mod.__name__} module defines the value {mod.pi} for PI"
print(s5.format(mod = math))                            #The math module defines the value 3.141592653589793 for PI






